package com.genesis.yunnanji.view;

import android.os.Bundle;
import android.view.View;
import android.widget.EditText;

import com.genesis.yunnanji.R;
import com.genesis.yunnanji.bean.MessageEventBean;
import com.youth.xframe.widget.XToast;

import org.greenrobot.eventbus.EventBus;

import butterknife.BindView;

/**
 * 创建日期：2018/9/21 on 16:41
 * 作者:Kite
 * 描述:设置昵称
 */
public class SetNicknameActivity extends BaseActivity {

    @BindView(R.id.et_nickname)
    EditText etNickname;

    @Override
    public int getLayoutId() {
        return R.layout.activity_set_nickname;
    }

    @Override
    public void initView() {
        super.initView();
        Bundle bundle = null;
        setTitle("昵称");
        if (bundle == null) {
            String p0 = getIntent().getStringExtra("p0");
            etNickname.setText(p0);
            etNickname.setSelection(etNickname.getText().length());
        }
        addMenuTextItem(R.string.save, new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (!etNickname.getText().toString().equals("")) {
                    EventBus.getDefault().post(new MessageEventBean(5, etNickname.getText().toString()));
                    finish();
                } else {
                    XToast.info("请输入昵称");
                }
            }
        });
    }

}
